package com.zzh.rest;

import com.zzh.dao.InfoRepository;
import com.zzh.model.Info.InfoDemo;
import com.zzh.utils.GeneralResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @PackageName:com.zzh.rest
 * @ClassName:ElasticSearchDemo
 * @Description:
 * @author:zhangzhanheng
 * @date: 2020/12/24 16:49
 */
@RestController
@RequestMapping("/text")
public class ElasticSearchDemo {
    @Autowired
    InfoRepository infoRepository;

    @GetMapping("/add")
    public void add() {
        InfoDemo infoDemo = InfoDemo.builder().id(1).userName("张三").email("135@153.com").build();
        infoRepository.save(infoDemo);
    }

    @GetMapping("/one")
    public GeneralResult one() {
        return GeneralResult.ok(infoRepository.findById(1L));
    }
}
